<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd         
                           http://www.springframework.org/schema/mvc
                           http://www.springframework.org/schema/mvc/spring-mvc.xsd">


	<!-- Define the controllers using annotations -->
	<context:component-scan base-package="de.fhd.pms.ctrl" />


	<!-- support JSR303 annotation if JSR 303 validation present on classpath -->
	<mvc:annotation-driven />

	<bean
		class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
	<bean
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

	<!-- ******************* -->
	<!-- DB and Hibernate -->
	<!-- ******************* -->

	<!-- <bean class="de.fhd.pms.Startup" init-method="initDB"> <property name="driverClass" 
		value="com.mysql.jdbc.Driver" /> <property name="user" value="hitch-user" 
		/> <property name="password" value="hitch-user" /> <property name="defaultDBurl" 
		value="jdbc:mysql://localhost:3306/mysql" /> <property name="newDB" value="hitch" 
		/> </bean> -->

	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
		destroy-method="close">
		<property name="driverClass" value="com.mysql.jdbc.Driver" />
		<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/hitch" />
		<property name="user" value="hitch-user" />
		<property name="password" value="hitch-user" />
		<property name="minPoolSize" value="2" />
		<property name="maxPoolSize" value="4" />
	</bean>

	<bean id="hibernateSessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="annotatedClasses">
			<list>
				<!-- <value>de.fhd.pms.model.Action</value> -->
				<value>de.fhd.pms.model.User</value>
				<value>de.fhd.pms.model.Tour</value>
				<value>de.fhd.pms.model.Action</value>
				<value>de.fhd.pms.model.UsersTour</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
	</bean>

	<!-- ******************* -->
	<!-- Data Access Objects -->
	<!-- ******************* -->

	<bean id="userDao" class="de.fhd.pms.dao.UserDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
	</bean>



	<bean id="tourDao" class="de.fhd.pms.dao.TourDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
		<property name="userDao" ref="userDao" />
		<property name="actionDao" ref="actionDao" />
	</bean>
	<!-- <bean id="UsersTourDao" class="de.fhd.pms.dao.UsersTourDao"> <property 
		name="sessionFactory" ref="hibernateSessionFactory" /> <property name="userDao" 
		ref="userDao"/> <property name="tourDao" ref="tourDao"/> </bean> -->
	<bean id="actionDao" class="de.fhd.pms.dao.ActionDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
		<property name="userDao" ref="userDao" />
	</bean>



	<!-- ******************* -->
	<!-- Controllers -->
	<!-- ******************* -->

	<bean id="userController" class="de.fhd.pms.ctrl.UserController">
		<property name="userDao" ref="userDao" />
	</bean>

	<bean id="tourController" class="de.fhd.pms.ctrl.TourController">
		<property name="tourDao" ref="tourDao" />
		<property name="userDao" ref="userDao" />
		<property name="usersTourDao" ref="usersTourDao" />
	</bean>

	<bean id="actionController" class="de.fhd.pms.ctrl.ActionController">
		<property name="actionDao" ref="actionDao" />
		<property name="userDao" ref="userDao" />
	</bean>
	<bean id="usersTourDao" class="de.fhd.pms.dao.UsersTourDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
	</bean>


	<!-- ******************* -->
	<!-- Views -->
	<!-- ******************* -->

	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/view/" />
		<property name="suffix" value=".jsp" />
	</bean>

	<bean id="messageSource"
		class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
		<property name="basename" value="/WEB-INF/messages" />
	</bean>

	<bean id="localeResolver"
		class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
</beans>